<%@page import="shmged.com.shlcm.utils.CmIBAHelper"%>
<%@include file = "/shmged/jsp/com/shlcm/portal/main/head.jsp" %>
<%@page import="wt.doc.WTDocument"%>
<%@page import="wt.fc.ReferenceFactory"%>

<%@page import="shmged.com.shlcm.utils.CmShmgedType"%>
<%@page import="shmged.com.shlcm.utils.CmSettings"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

	
<%
    
	String oid = request.getParameter("oid").trim();
	ReferenceFactory rf = new ReferenceFactory();
	WTDocument doc = (WTDocument)rf.getReference(oid).getObject();
	CmIBAHelper holder = new CmIBAHelper(doc);
	String title = doc.getName();
	String number=doc.getNumber();
%>
<head>
    <title>创建项目计划</title>
</head>

<body>
<center>
<div style="display:none" >
<div style="width: 560px;height: auto" id="<%=uuid %>browseCreateProjectSchedule" >

<form id="createProjectSchedu" method="post" ENCTYPE="multipart/form-data" action="<%=baseUrl %>shmged/jsp/com/shlcm/projects/createService.jsp">
     <input type="hidden" name="CONFcontainerName" value="<%=CmSettings.getSection("DefaultLocation").get("ShmgedContainer", "海洋运营库") %>" />
	 <input type="hidden" name="CONFfolderPath" value="<%=CmSettings.getSection("DefaultLocation").get("ProjectScheduleEntryFoler", "/Default") %>" />
	 <input type="hidden" name="CONFsoftType" value="<%=CmShmgedType.ProjectScheduleEntry %>" />
	 <input  type="hidden" value="<%=number %>" name="IBAProjectNo" ></input>
	<table border="1px" bordercolor="00BFFF" cellspacing="0px" style="border-collapse:collapse" class="easyui-panel" width="100%">
		<tr>
			<td rowspan=1 colspan=4  align=center  height="40">项目计划</td>
   		</tr>
		<tr>
			<td align="right">项目计划名称:</td>
			<td colspan="3"><input class="easyui-validatebox" type="text" name="MBAname" data-options="required:true,missingMessage:'项目进度名称！'" size="60"></input></td>
		</tr>
		<tr>
			<td align="right">上传项目计划附件:</td>
			<td colspan="3"><input type="file" name="inp_primary_file" size="50" id="inp_primary_file"/></td>
		</tr>
		</table>
		<br>
</form>

	    <div style="text-align:center;padding:5px;">
	    	<a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">提交</a>
	    	<a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()">重置</a>
	    </div>
	     <div style="display: none;">
	      <form action="<%=baseUrl %>shmged/jsp/com/shlcm/projects/viewProjectSchedule.jsp" id="jumpPageId">
	          <input type="hidden" name="oid" value="" id="jumpOidId"/> 
	      </form>
	    </div>
<SCRIPT LANGUAGE="JavaScript">
$(function(){  
    $('#<%=uuid%>IBAParentTask').combogrid({  
         panelWidth:250,   
         idField:'number',  
         textField:'docName', 
         queryParams:{folderName:"/Default/项目管理/项目信息",projectNo:"<%=number%>"}, 
         url:'<%=baseUrl%>shmged/jsp/com/shlcm/projects/jspSearchDocByProject.jsp',  
         columns:[[  
             {field:'number',title:'编号',width:60},  
            {field:'docName',title:'名称',width:100}
         ]],
        onSelect:function(record){
              var r = $(this).datagrid('getSelected');
             // if(r.ContactNo != null){
              	$('#createReimbursement_ContactNo').val(r.ContactNo);  
             // }
            // alert(r.ContactNo);
        }   
    });  
});  



$(function(){  
    $('#<%=uuid%>IBABeforeTask').combogrid({  
         panelWidth:250,   
         idField:'number',  
         textField:'docName', 
         queryParams:{folderName:"/Default/项目管理/项目信息",projectNo:"<%=number%>"}, 
         url:'<%=baseUrl%>shmged/jsp/com/shlcm/projects/jspSearchDocByProject.jsp',  
         columns:[[  
             {field:'number',title:'编号',width:60},  
            {field:'docName',title:'名称',width:100}
         ]],
        onSelect:function(record){
              var r = $(this).datagrid('getSelected');
             // if(r.ContactNo != null){
              	$('#createReimbursement_ContactNo').val(r.ContactNo);  
             // }
            // alert(r.ContactNo);
        }   
    });  
});  


function submitForm(){
	$('#<%=uuid%>createProjectSchedu').form('submit',{
		onSubmit:function (){
			//alert("amCreateProject");
			var fileVal = $("#inp_primary_file").val();
			if("" == fileVal){
				alert("请选择项目文件!");
				return false;
			}
			//alert(fileVal);
			var upfile = fileVal.toUpperCase();
			//alert(upfile);
			//alert(upfile.length);
			var index = upfile.lastIndexOf(".XLS");
			if(upfile.length != (index + ".XLS".length)){
				alert("项目计划文件只能是xls文件!");
				return false;
			}
			//return true;
			//alert(index);
		},
		success:function (data){
			//alert(data);
			if(data.indexOf("ERROR:") != -1){
				alert(data);
			}else{
				refeProjectSch();
				$('#browseCreateProjectSchedule').window('close');
			}
		}
	});
	//$('#createProjectSchedu').form('submit');
	//$('#amCreateProject').form('submit');
	//$('#createProjectSchedu').submit();
	
}
function clearForm(){
	$('#createProjectSchedu').form('clear');
}


function browseCreateProjectSchedule(){
	  $('#browseCreateProjectSchedule').window({
		     collapsible:false,
		     minimizable:false,
		     maximizable:false,
		     resizable:false,
		     title:"创建项目计划",
			 width:580,
		     //height:550,
		     modal:true,
		     left:300,
		     onClose:function(){
		  		refeProjectSch();
		  	 $('#browseCreateProjectSchedule').window("destroy");
		     }
		 });
}



function refeProjectSch(){
	
		var number='<%=number%>信息';
		$("#cmTabs").tabs('select',number);  
	  var tab = $('#cmTabs').tabs('getSelected');
	  $("#cmTabs").tabs('update',{  
	  tab:tab,  
	  options:{  
	     title:number,  
	     style:{padding:'1px'},  
	 //href:URL, // 使用href会导致页面加载两次，所以使用content代替   
	     content:'<iframe name="indextab" scrolling="auto" frameborder="0" style="width:100%;height:100%;"></iframe>',  
		 closable:false,  
		 fit:true,  
		 selected:true,  
		 closable:true
	  }  
   });  
}

</script>
</div>
</div>
</center>
</body>

